<template>
	<view class="wrap">
		<view class="ask">
			<view class="ask-info">
				<view class="info-list flex flex-between flex-row" v-for="(item ,index) in infoList" :key="index" @click="jumpDetail(item.id)">
					<view class="lt flex flex-col flex-between">
						<view class="title twoline">{{item.title}}</view>
						<view class="time-zan flex flex-between flex-v-center">
							<view class="time">{{item.updateBy||''}} {{item.updateTime}}</view>
							<view class="zan">点赞：{{item.zanNum}}</view>
						</view>
					</view>
					<view class="rt">
						<image :src="item.coverImg" mode=""></image>
					</view>
					<!-- <view class="collects flex flex-h-end flex-v-center" v-if="collect==1">
						<image src="../static/image/009.png" mode=""></image>
						<text class="collect">收藏</text>
					</view>
					<view class="collects flex flex-h-end flex-v-center" v-else>
						<image src="../static/image/010.png" mode=""></image>
						<text class="collected">取消收藏</text>
					</view> -->
				</view>
				<u-loadmore :status="status" v-if="infoList.length>0"  :icon-type="iconType" :load-text="loadText" color='#ccc' />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isMore:false,
				isLoad:false,
				infoList:[],
				status:'loadmore',// loading / nomore
				iconType: 'flower',
				loadText: {
					loadmore: '到底了',
					loading: '努力加载中',
					nomore: '到底了'
				},
				
				pageNum:1,
				TotalPageCount:0,
				touch:false
			}
		},
		onLoad() {
			this.getInfo();
		},
		onShow() {
			if(!this.touch){
				this.status="nomore";
			}
		},
		onReachBottom(){
			if(this.pageNum >= this.TotalPageCount){
				this.status = 'nomore';
				return;
			}
			if(this.pageNum<this.TotalPageCount){
				this.pageNum++;
				this.getInfo();
			}
		},
		onPullDownRefresh(){
			
			setTimeout(function(){
				uni.stopPullDownRefresh()
			},300)
		},
		methods: {
			getInfo() {
				let that = this;
				this.$https.request('/cli/news/list', true, {
					pageNum:that.pageNum,
					pageSize:10
				}).then((res) => {
					
					if (res.code == 0) {
						that.TotalPageCount = res.data.pages;
						if(that.pageNum==1){
							that.infoList = res.data.list;
						}else{
							that.infoList = that.infoList.concat(res.data.list);
						}
						if(that.pageNum == that.pages){
							that.status = 'nomore';
						}else{
							that.status = 'loadmore';
						}
			
					}else if (res.code == 201) {
						uni.navigateTo({
							url:'../login/login'
						})

					} else {
						this.LoadingMsg(res.msg);
						setTimeout(function() {
							uni.hideLoading();
						}, 1000)
					}
			
				})
			},
			jumpDetail(id) {
				console.log(id)
				uni.navigateTo({
					url: "./message?id="+id
				})
			},
		}
	}
</script>
<style>
	page{
		 background-color: #F6FAFD;
	}
</style>
<style scoped lang="scss">
	
   .wrap{
	  
	   .ask{
	   	padding: 30rpx 0;
	   	.ask-info{
	   		padding-top: 40rpx;
	   		.info-list{
				padding: 30rpx;
				margin-bottom: 40rpx;
				background-color: #fff;
	   			.lt{
	   				width: calc(100% - 220rpx);
	   				padding-right: 40rpx;
	   				.title{
	   					font-family: HiraginoSansGB-W6;
	   					font-size: 28rpx;
	   					color: #333;
	   				}
	   				.time-zan{
	   					.time{
	   						font-family: HiraginoSansGB-W3;
	   						font-size: 24rpx;
	   						color: #999;
	   					}
	   					.zan{
	   						font-family: HiraginoSansGB-W3;
	   						font-size: 24rpx;
	   						color: #999;
	   					}
	   				}
	   			}
	   			.rt{
	   				width:220rpx ;
	   				image{
	   					width: 220rpx;
	   					height: 150rpx;
						border-radius: 20rpx;
	   				}
	   			}
				.collects{
					padding-top: 40rpx;
					width: 100%;
					image{
						width: 30rpx;
						height: 30rpx;
					}
					.collect{
						font-family: HiraginoSansGB-W3;
						font-size: 24rpx;
						color: #999;
						padding-left: 8rpx;
					}
					.collected{
						font-family: HiraginoSansGB-W3;
						font-size: 24rpx;
						color: #2A90FF;
						padding-left: 8rpx;
					}
				}
	   		}
	   		
	   	}
	   	.ask-top{
	   		.title{
	   			font-family: HiraginoSansGB-W6;
	   			font-size: 30rpx;
	   			color: #000000;
	   			font-weight: 900;
	   		}
	   		.more{
	   			font-family: HiraginoSansGB-W3;
	   			font-size: 24rpx;
	   			color: #666;
	   		}
	   	}
	   }
   }
</style>
